import JSEncrypt from 'jsencrypt'

// 密钥对生成 http://web.chacuo.net/netrsakeypair

const publicKey =
  'MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCDHVCZKyj10H3CTQTC0hQwbzQby6hB5b19IFajXAII8Z7F1RXCf47ybyFQqLD5S2mfzUs53W+jU5TEH6Akwd3XTx1SI2T2jFgFc01Hwu7ODxrftgxEUKx+zZs/TTmC1v2mt/GBkNof3vjfLTQY79bPpsLlK1qdxesPF5q2otaxcQIDAQAB'
// 开源秘钥
const privateKey =
  '欢迎关注zkmall开源社区,gitee仓库地址: https://gitee.com/zkmall 喜欢就给个关注吧!!!!'

// 加密
export function encrypt(txt) {
  const encryptor = new JSEncrypt()
  encryptor.setPublicKey(publicKey) // 设置公钥
  return encryptor.encrypt(txt) // 对需要加密的数据进行加密
}

// 解密
export function decrypt(txt) {
  const encryptor = new JSEncrypt()
  encryptor.setPrivateKey(privateKey)
  return encryptor.decrypt(txt)
}
